{% load i18n %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
{#Changed jb7rA8Ye6cX4 #}

<html>
<head>
    <title>{%trans "Auction Site" %}</title>
</head>
<style>
   table, th, td{
    border: 1px solid #333;
   }
</style>
<body>
	<a href ='/home/'>{% trans 'Home'%}</a>
	<a href ='/home/category/'>{% trans 'Browse Category'%}</a>
	<a href ='/create/'>{% trans 'Create Auction'%}</a>
	<a style="color:red;">{{msg}}</a>

    {% if logged_in %}
      <form action="/logout/">
        <input type="submit" value={% trans "Logout"%}>
      </form>
    {% endif %}

    <label>{% trans 'Language:'%}</label>
	<a href ='/language/en/'>EN/</a>
	<a href ='/language/fi/'>FI/</a>
    <a href ='/language/sv/'>SV/</a>

{#    This form is responsible for the search criteria and is displayed only in the home page#}
	<form method = "POST" action="/home/title/">
		{% csrf_token %}
        <p>{% trans 'Criteria'%} <input type="text" name="search">
        <input type="submit" value={% trans 'Search'%}></p>
    </form>
{#    These block of content are shown only if the user is not logged in.#}
	{% if not logged_in %}
	<form method = "POST" action="/login/">
	{% csrf_token %}
		<p>{% trans 'Username:'%} <input type="text" name="username"></p>
		<p>{% trans 'Password:'%} <input type="password" name="password"></p>
		<input type="submit" value={% trans 'Submit:'%}>
		<label>{% trans "Don\'t have an account?" %} <a href = '/adduser/'>{% trans 'Click Here'%}</a></label>
	</form>
	{% endif %}
{#    It shows the list of Auction in the table created below#}
	<table>
		<caption><h3>{% trans 'Newest Auctions' %}</h3></caption>
		<thead>
		<tr>
			<th>{% trans 'Auction Title'%}</th>
			<th>{% trans 'Category'%}</th>
			<th>{% trans 'Start date'%}</th>
			<th>{% trans 'End date'%}</th>
		</tr>
		</thead>
		<tbody>
        {% for auc in auction_list %}
                <tr>
                    <td><a href="/item/{{auc.id}}">{{ auc.title }}</a></td>
                    <td>{{ auc.category }}</td>
                    <td>{{ auc.sDate }}</td>
                    <td>{{ auc.eDate }}</td>
                </tr>
        {% endfor %}
		</tbody>
	</table>
</body>
</html>